# dnf install mingw32-gcc mingw32-win-iconv
# apt install mingw-w64
#gcc *.c -lm && cp a.out ~/jiapu2/src/print/
ifeq ($(OS),Windows_NT)
PWD:=$(shell cd)
#PWD:=
#PWD:=.
TARGET:=$(PWD)/a.exe
CC:=gcc
CFLAGS:=-lm -liconv -I"include/freetype2/" -I"include"
else
PWD:=$(shell pwd)
TARGET:=$(PWD)/a.exe
CC:=i686-w64-mingw32-gcc
CFLAGS:=-lm libiconv2.dll -I"include/freetype2/" -I"include"
endif

SRC_DIR:=.
SRC:= $(foreach x,${SRC_DIR}, $(wildcard $(addprefix ${x}/*,.c)))
OBJS:=$(patsubst %.c,%.o,$(SRC))

all:$(TARGET)
ifeq ($(OS),Windows_NT)
	$(TARGET) ..\test.pdf "C:/Users/Administrator/AppData/Roaming/com.huaien.jiapu2/Local Store/100004/s/"
#	$(TARGET) ../test.pdf "c:/Users/Administrator/Desktop/100004/x/"
#	$(TARGET) ../test.pdf "E:/Desktop/11376903/w/"
#	$(TARGET) ../test.pdf "E:/Desktop/100004/h/"
#	$(TARGET) ../test.pdf "c:/Users/Administrator/Desktop/11350736/s/"
#	$(TARGET) ../test.pdf "c:/Users/Administrator/Desktop/11350736/w/"
	copy a.exe ..\Documents\print\a.exe
	copy a.exe f:\jiapu2\src\print\a.exe
	cmd /c ..\test.pdf
else
	cp $(TARGET) ~/jiapu2/src/print/
	cp $(TARGET) ~/print/
#	cp $(TARGET) ~/back/Documents/print/
	@echo OK
#	$(TARGET) ../test.pdf "~/Desktop/100004/h/"
endif

$(TARGET):$(OBJS)
ifeq ($(OS),Windows_NT)
#	$(CC) -o $@ $^ $(CFLAGS) "freetype6.dll"
	$(CC) -o $@ $^ $(CFLAGS)
#lib/freetype.lib
else
	$(CC) -o $@ $^ $(CFLAGS)
endif

.c.o:
	$(CC) $(CFLAGS) -c $<

.PHONY : clean
clean:
	$(RM) $(TARGET) *.o *.exe *.pdf

git:
#git init && git config receive.denyCurrentBranch ignore
	git remote -v
	git remote add origin pi@rpi:~/pdf
	git push -u origin master


